/**
 * @JSONCodecUtils.java  COPYRIGHT xiaojian
 * 
 * Created on 2016年7月18日 下午2:56:26
 */
package xj.toolkit.bean.json.meta;

import java.util.Collection;

import org.apache.commons.collections4.Transformer;

import xj.toolkit.bean.json.annotation.JSONMessage;
import xj.toolkit.bean.util.meta.BeanMetainfoUtils;
import xj.toolkit.bean.util.meta.Int2TypeMetainfo;

/**
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
public class JSONCodecUtils {

	private static final Transformer CLS2INT = new Transformer() {

		public Object transform(Object input) {
			Class<?> cls = (Class<?>) input;
			JSONMessage attr = cls.getAnnotation(JSONMessage.class);
			return null != attr ? attr.messageCode() : null;
		}
	};

	static public Int2TypeMetainfo createTopmostTypeMetainfo(Collection<String> packages) {
		return BeanMetainfoUtils.createTypeMetainfo(packages, CLS2INT);
	}
}
